package top.fwpsl.data;

import java.util.Objects;

/**
 * @author 风戏fw
 */
public class PersonModel implements Comparable<PersonModel>, Cloneable {

    private String name;

    private int age;

    private String sex;

    public PersonModel() {
    }

    public PersonModel(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PersonModel that = (PersonModel) o;
        return Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sex);
    }

    @Override
    public String toString() {
        return "{" +
                "\"name\":\"" + name + '\"' +
                ", \"age\":" + age +
                ", \"sex\":\"" + sex + '\"' +
                '}';
    }

    @Override
    public int compareTo(PersonModel o) {
        if (getAge() == o.getAge()) {
            return 0;
        }
        return getAge() < o.getAge()? 1: -1;
    }


}
